
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>1.依赖注入和控制反转 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="003模块.html" />
    
    
    <link rel="prev" href="001介绍Spring框架.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    文档介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../第一章/001入门指南.html">
            
                <a href="../第一章/001入门指南.html">
            
                    
                    一、入门指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="001介绍Spring框架.html">
            
                <a href="001介绍Spring框架.html">
            
                    
                    二、介绍Spring框架
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.3.1" data-path="002依赖注入和控制反转.html">
            
                <a href="002依赖注入和控制反转.html">
            
                    
                    1.依赖注入和控制反转
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="003模块.html">
            
                <a href="003模块.html">
            
                    
                    2.模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="004使用场景.html">
            
                <a href="004使用场景.html">
            
                    
                    3.使用场景
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >1.依赖注入和控制反转</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="1-&#x4F9D;&#x8D56;&#x6CE8;&#x5165;&#x548C;&#x63A7;&#x5236;&#x53CD;&#x8F6C;">1. &#x4F9D;&#x8D56;&#x6CE8;&#x5165;&#x548C;&#x63A7;&#x5236;&#x53CD;&#x8F6C;</h1>
<p>Java&#x5E94;&#x7528;&#x7A0B;&#x5E8F;-&#x8FD9;&#x662F;&#x4E00;&#x4E2A;&#x5BBD;&#x677E;&#x7684;&#x672F;&#x8BED;&#xFF0C;&#x5B83;&#x5305;&#x62EC;&#x7684;&#x8303;&#x56F4;&#x4ECE;&#x53D7;&#x9650;&#x7684;&#x5D4C;&#x5165;&#x5F0F;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x5230;n&#x5C42;&#x7684;&#x670D;&#x52A1;&#x5668;&#x7AEF;&#x4F01;&#x4E1A;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;-&#x901A;&#x5E38;&#x7EC4;&#x6210;&#x7A0B;&#x5E8F;&#x7684;&#x5BF9;&#x8C61;&#x4E92;&#x76F8;&#x534F;&#x4F5C;&#x800C;&#x6784;&#x6210;&#x6B63;&#x786E;&#x7684;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x3002;&#x56E0;&#x6B64;&#xFF0C;&#x5728;&#x4E00;&#x4E2A;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x4E2D;&#x7684;&#x5BF9;&#x8C61;&#x5F7C;&#x6B64;&#x5177;&#x6709;<em>&#x4F9D;&#x8D56;&#x5173;&#x7CFB;&#xFF08;dependencies&#xFF09;&#x3002;</em></p>
<p>&#x867D;&#x7136;Java&#x5E73;&#x53F0;&#x63D0;&#x4F9B;&#x4E86;&#x4E30;&#x5BCC;&#x7684;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x5F00;&#x53D1;&#x529F;&#x80FD;&#xFF0C;&#x4F46;&#x5B83;&#x7F3A;&#x4E4F;&#x5C06;&#x57FA;&#x672C;&#x7684;&#x6A21;&#x5757;&#x7EC4;&#x7EC7;&#x6210;&#x4E00;&#x4E2A;&#x6574;&#x4F53;&#x7684;&#x65B9;&#x6CD5;&#xFF0C;&#x800C;&#x5C06;&#x8BE5;&#x4EFB;&#x52A1;&#x7559;&#x7ED9;&#x4E86;&#x67B6;&#x6784;&#x5E08;&#x548C;&#x5F00;&#x53D1;&#x4EBA;&#x5458;&#x3002;&#x867D;&#x7136;&#x4F60;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5982;<em>&#x5DE5;&#x5382;</em>&#xFF0C;<em>&#x62BD;&#x8C61;&#x5DE5;&#x5382;</em>&#xFF0C;<em>Builder</em>&#xFF0C;<em>&#x88C5;&#x9970;&#x5668;</em>&#x548C;<em>Service Locator&#x7B49;</em> &#x8BBE;&#x8BA1;&#x6A21;&#x5F0F;&#x6765;&#x6784;&#x5EFA;&#x5404;&#x79CD;&#x7C7B;&#x548C;&#x5BF9;&#x8C61;&#x5B9E;&#x4F8B;&#xFF0C;&#x4F7F;&#x4ED6;&#x4EEC;&#x7EC4;&#x5408;&#x6210;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#xFF0C;&#x4F46;&#x8FD9;&#x4E9B;&#x6A21;&#x5F0F;&#x65E0;&#x975E;&#x53EA;&#x662F;&#xFF1A;&#x6700;&#x4F73;&#x5B9E;&#x8DF5;&#x8D4B;&#x4E88;&#x7684;&#x4E00;&#x4E2A;&#x540D;&#x5B57;&#xFF0C;&#x4EE5;&#x53CA;&#x8FD9;&#x662F;&#x4EC0;&#x4E48;&#x6837;&#x7684;&#x6A21;&#x5F0F;&#xFF0C;&#x5E94;&#x7528;&#x4E8E;&#x54EA;&#x91CC;&#xFF0C;&#x5B83;&#x80FD;&#x89E3;&#x51B3;&#x7684;&#x95EE;&#x9898;&#x7B49;&#x7B49;&#x3002; &#x6A21;&#x5F0F;&#x662F;&#x60A8;&#x5FC5;&#x987B;&#x5728;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x4E2D;&#x81EA;&#x5DF1;&#x5B9E;&#x73B0;&#x7684;&#x5F62;&#x5F0F;&#x5316;&#x7684;&#x6700;&#x4F73;&#x5B9E;&#x8DF5;&#x3002;</p>
<p>Spring&#x6846;&#x67B6;<em>&#x63A7;&#x5236;&#x53CD;&#x8F6C;</em>&#xFF08;IOC&#xFF09;&#x7EC4;&#x4EF6;&#x901A;&#x8FC7;&#x63D0;&#x4F9B;&#x4E00;&#x7CFB;&#x5217;&#x7684;&#x6807;&#x51C6;&#x5316;&#x7684;&#x65B9;&#x6CD5;&#x628A;&#x5B8C;&#x5168;&#x4E0D;&#x540C;&#x7684;&#x7EC4;&#x4EF6;&#x7EC4;&#x5408;&#x6210;&#x4E00;&#x4E2A;&#x80FD;&#x591F;&#x4F7F;&#x7528;&#x7684;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x6765;&#x89E3;&#x51B3;&#x8FD9;&#x4E2A;&#x95EE;&#x9898;&#x3002;Spring&#x6846;&#x67B6;&#x628A;&#x5F62;&#x5F0F;&#x5316;&#x7684;&#x8BBE;&#x8BA1;&#x6A21;&#x5F0F;&#x7F16;&#x5199;&#x4E3A;&#x4F18;&#x79C0;&#x7684;&#x5BF9;&#x8C61;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x5BB9;&#x6613;&#x7684;&#x96C6;&#x6210;&#x5230;&#x81EA;&#x5DF1;&#x7684;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x4E2D;&#x3002;&#x8BB8;&#x591A;&#x7EC4;&#x7EC7;&#x548C;&#x673A;&#x6784;&#x4F7F;&#x7528;Spring&#x6846;&#x67B6;&#xFF0C;&#x4EE5;&#x8FD9;&#x79CD;&#x65B9;&#x5F0F;(&#x4F7F;&#x7528;Spring&#x7684;&#x6A21;&#x5F0F;&#x5BF9;&#x8C61;)&#x6765;&#x8BBE;&#x8BA1;&#x5065;&#x58EE;&#x7684;&#xFF0C;<em>&#x53EF;&#x7EF4;&#x62A4;&#x7684;</em>&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x3002;</p>
<p><strong>&#x80CC;&#x666F;</strong></p>
<p>&#x201C; &#x73B0;&#x5728;&#x7684;&#x95EE;&#x9898;&#x662F;&#xFF0C;&#x4EC0;&#x4E48;&#x65B9;&#x9762;&#x7684;&#x63A7;&#x5236;&#x88AB;&#xFF08;&#x4ED6;&#x4EEC;&#xFF09;&#x53CD;&#x8F6C;&#x4E86;&#xFF1F; &#x201D;&#x9A6C;&#x4E01;&#xB7;&#x798F;&#x52D2;2004&#x5E74;&#x5728;<a href="http://martinfowler.com/articles/injection.html" target="_blank">&#x4ED6;&#x7684;&#x7F51;&#x7AD9;</a>&#x63D0;&#x51FA;&#x4E86;&#x8FD9;&#x4E2A;&#x6709;&#x5173;&#x63A7;&#x5236;&#x53CD;&#x8F6C;&#xFF08;IOC&#xFF09;&#x7684;&#x95EE;&#x9898; &#xFF0C;&#x798F;&#x52D2;&#x5EFA;&#x8BAE;&#x91CD;&#x547D;&#x540D;&#xFF0C;&#x4F7F;&#x4E4B;&#x80FD;&#x591F;&#x81EA;&#x6211;&#x63CF;&#x8FF0;&#xFF0C;&#x5E76;&#x63D0;&#x51FA;&#x4E86;&#x4F9D;&#x8D56;&#x6CE8;&#x5165;( <em>Dependency Injection</em>)&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="001介绍Spring框架.html" class="navigation navigation-prev " aria-label="Previous page: 二、介绍Spring框架">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="003模块.html" class="navigation navigation-next " aria-label="Next page: 2.模块">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"1.依赖注入和控制反转","level":"1.3.1","depth":2,"next":{"title":"2.模块","level":"1.3.2","depth":2,"path":"第二章/003模块.md","ref":"第二章/003模块.md","articles":[]},"previous":{"title":"二、介绍Spring框架","level":"1.3","depth":1,"path":"第二章/001介绍Spring框架.md","ref":"第二章/001介绍Spring框架.md","articles":[{"title":"1.依赖注入和控制反转","level":"1.3.1","depth":2,"path":"第二章/002依赖注入和控制反转.md","ref":"第二章/002依赖注入和控制反转.md","articles":[]},{"title":"2.模块","level":"1.3.2","depth":2,"path":"第二章/003模块.md","ref":"第二章/003模块.md","articles":[]},{"title":"3.使用场景","level":"1.3.3","depth":2,"path":"第二章/004使用场景.md","ref":"第二章/004使用场景.md","articles":[]}]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["livereload"],"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"第二章/002依赖注入和控制反转.md","mtime":"2019-04-11T05:20:44.112Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-04-11T07:41:12.428Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

